package chapter04;

public class Test06_instance {
    public static void main(String[] args) {
        Person p = new Person();
        Person s = new Student();
        getInfo(p);
        getInfo(s);
        System.out.println(p.toString());
    }
    public static void getInfo(Person p){
        //判断是否是子类对象
        if(p instanceof Student){
            System.out.println("传入的是学生");
        }else{
            System.out.println("传入的是人");
        }
    }
}
class Person{
    @Override
    public String toString() {
        return "我是一个人";
    }
}
class Student extends Person{ }
